using UnityEngine;

public class C_土地庙 : MonoBehaviour
{
	public Transform _Tsf_UI;

	private ItemUI_存档点 _ItemUI_存档点;

	private Vector2 _Pos1;

	private Vector2 _Pos2;

	private void Start()
	{
		_ItemUI_存档点 = MonoSingleton<GameManager>.Instance.F_Get_ItemUI_存档点();
		_ItemUI_存档点._可见性 = false;
		_ItemUI_存档点.F_SetPos(_Tsf_UI.position);
		BoxCollider2D component = GetComponent<BoxCollider2D>();
		Vector2 vector = base.transform.position;
		Vector2 vector2 = component.size / 2f;
		_Pos1 = vector - vector2;
		_Pos2 = vector + vector2;
	}

	public Vector2 F_得到范围内随机点()
	{
		return new Vector2(Random.Range(_Pos1.x, _Pos2.x), Random.Range(_Pos1.y, _Pos2.y));
	}

	private void OnDestroy()
	{
		if (_ItemUI_存档点 != null)
		{
			Object.Destroy(_ItemUI_存档点.gameObject);
		}
	}

	private void OnTriggerEnter2D(Collider2D collision)
	{
		if (collision.tag == "Player")
		{
			_ItemUI_存档点.F_SetPos(_Tsf_UI.position);
			_ItemUI_存档点._可见性 = true;
		}
	}

	private void OnTriggerExit2D(Collider2D collision)
	{
		if (collision.tag == "Player")
		{
			_ItemUI_存档点._可见性 = false;
		}
	}
}
